/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JLabel;
import model.Kort;
import utility.Card;
import utility.ImageToolbox;

/**
 *
 * @author Jeppe
 */
public class KortPanel extends javax.swing.JPanel {

    private PlayersHand playersHand;
    private ImageToolbox imgTB;
    private Kort kort;
    
    private final static boolean debugMode = false;
    
    /**
     * Viser det valgte kort på hele panelet.
     *
     * @param kort
     * @param d
     */
    public KortPanel(final Kort kort, Dimension d, PlayersHand playersHand) {
        this.playersHand = playersHand;
        this.kort = kort;
        initComponents();
        setSize(d);
        remove(kortLabel);
        kortLabel = new JLabel(){
            public void paint(Graphics g) {
                super.paint(g);
                imgTB.drawImage(g, kort.getImageIcon(), 0, 0, 146, 205);
            }
        };
        
        kortLabel.setVisible(true);
        kortLabel.setBounds(0, 0, 146, 205);
        add(kortLabel);
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        kortKnap = new javax.swing.JButton();
        kortLabel = new javax.swing.JLabel();

        setOpaque(false);
        setPreferredSize(new java.awt.Dimension(146, 205));
        setLayout(null);

        kortKnap.setBorderPainted(false);
        kortKnap.setContentAreaFilled(false);
        kortKnap.setFocusPainted(false);
        kortKnap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kortKnapActionPerformed(evt);
            }
        });
        add(kortKnap);
        kortKnap.setBounds(0, 0, 150, 210);
        add(kortLabel);
        kortLabel.setBounds(0, 0, 150, 210);
    }// </editor-fold>//GEN-END:initComponents

    private void kortKnapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kortKnapActionPerformed
        if(debugMode){
        System.out.println("Du har trykket på "+kort.toString());
        }
        playersHand.lægKortned(kort);
    }//GEN-LAST:event_kortKnapActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton kortKnap;
    private javax.swing.JLabel kortLabel;
    // End of variables declaration//GEN-END:variables
}
